package com.aop;

import org.aspectj.lang.JoinPoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

public class LoggerAspect {
    private static  final Logger log= LoggerFactory.getLogger(LoggerAspect.class);


    //前置增强
    public void before(JoinPoint jp){
        log.info("前置增强 正在调用{} 的{}方法。方法入参：{}",
                jp.getTarget(),jp.getSignature().getName(),
                Arrays.toString(jp.getArgs()));
    }


    public void  afterThrowing(JoinPoint jp,Throwable e)  {
        log.info("TransactionAspect异常抛出增强模拟业务异常回滚事务，异常信息为："+e.getMessage());
        log.info("session.rollback();");
    }

    //后置增强
    public void after(JoinPoint jp) {
        log.info("最终增强");
    }


}
